<%--
$Id: book-list.jsp 24 2011-06-17 13:31:30Z feigme $
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<%@ taglib prefix="iary" uri="/WEB-INF/tld/pagination.tld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><fmt:message key="user.manager"/></title>
<link href="${ctx }/css/admin/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<br/>
<form:form action="${ctx }/admin/book/search.do" method="post">
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<tr>
		<th colspan="4"><fmt:message key="common.query"/></th>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="common.id"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2"><form:input path="id"/></td>
		<td class="usertablerow2"><fmt:message key="book.name"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2"><form:input path="name"/></td>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.author"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2"><form:input path="author"/></td>
		<td class="usertablerow2"><fmt:message key="book.status"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<form:select path="status">
				<form:option value=""><fmt:message key="common.please.select"/></form:option>
				<c:forEach items="${command.statusList}" var="varStatus">
				<c:choose>
					<c:when test="${varStatus == command.status}">
						<option selected="selected" value="${varStatus}"><fmt:message key="book.status.${varStatus}"/></option> 
					</c:when>
					<c:otherwise>
						<option value="${varStatus}"><fmt:message key="book.status.${varStatus}"/></option> 
					</c:otherwise>
				</c:choose>
				</c:forEach>
			</form:select>
		</td>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.category"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<form:select path="category">
				<form:option value=""><fmt:message key="common.please.select"/></form:option>
				<c:forEach items="${command.categoryList}" var="varCategory">
				<c:choose>
					<c:when test="${varCategory == command.category}">
						<option selected="selected" value="${varCategory}"><fmt:message key="book.category.${varCategory}"/></option> 
					</c:when>
					<c:otherwise>
						<option value="${varCategory}"><fmt:message key="book.category.${varCategory}"/></option> 
					</c:otherwise>
				</c:choose>
				</c:forEach>
			</form:select>
		</td>
		<td class="usertablerow2"><fmt:message key="book.index"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<form:select path="index">
				<form:option value=""><fmt:message key="common.please.select"/></form:option>
				<c:forEach items="${command.indexList}" var="varIndex">
				<c:choose>
					<c:when test="${varIndex == command.index}">
						<option selected="selected" value="${varIndex}">${varIndex}</option> 
					</c:when>
					<c:otherwise>
						<option value="${varIndex}">${varIndex}</option> 
					</c:otherwise>
				</c:choose>
				</c:forEach>
			</form:select>
		</td>
	</tr>
	<tr>
		<td class="usertablerow2"><fmt:message key="book.area"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2">
			<form:select path="area">
				<option value=""><fmt:message key="common.please.select"/></option>
				<c:forEach items="${command.areaList}" var="varArea">
				<c:choose>
					<c:when test="${varArea == command.area}">
						<option selected="selected" value="${varArea}"><fmt:message key="book.area.${varArea}"/></option> 
					</c:when>
					<c:otherwise>
						<option value="${varArea}"><fmt:message key="book.area.${varArea}"/></option> 
					</c:otherwise>
				</c:choose>
				</c:forEach>
			</form:select>
		</td>
		<td class="usertablerow2"><fmt:message key="book.description"/><fmt:message key="common.colon"/></td>
		<td class="usertablerow2"><form:input path="description"/></td>
	</tr>
	<tr>
		<td class="usertablerow2" colspan="4"><input type="submit" value="<fmt:message key="common.query"/>"/></td>
	</tr>
</table>
</form:form>

<br/>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
	<tr>
		<th><fmt:message key="common.id"/></th>
		<th><fmt:message key="book.name"/></th>
		<th><fmt:message key="book.author"/></th>
		<th><fmt:message key="book.status"/></th>
		<th><fmt:message key="book.category"/></th>
		<th><fmt:message key="book.index"/></th>
		<th><fmt:message key="book.area"/></th>
		<th><fmt:message key="common.action"/></th>
	</tr>
	<c:if test="${page!=null}">
	<c:forEach items="${page.result}" var="book" varStatus="index">
	<tr>
		<td class="usertablerow2" align="center"><c:out value="${book.id}"/></td>
		<td class="usertablerow2"><c:out value="${book.name}"/></td>
		<td class="usertablerow2"><c:out value="${book.bookDesc.author}"/></td>
		<td class="usertablerow2">
			<c:if test="${book.bookDesc.status!=null}">
				<fmt:message key="book.status.${book.bookDesc.status}"/>
			</c:if>
		</td>
		<td class="usertablerow2">
			<c:if test="${book.bookDesc.category!=null}">
				<fmt:message key="book.category.${book.bookDesc.category}"/>
			</c:if>
		</td>
		<td class="usertablerow2"><c:out value="${book.bookDesc.index}"/></td>
		<td class="usertablerow2">
			<c:if test="${book.bookDesc.area!=null}">
				<fmt:message key="book.area.${book.bookDesc.area}"/>
			</c:if>	
		</td>
		<td class="usertablerow2">
			<a href="${ctx }/admin/book/edit.do?id=<c:out value="${book.id}"/>"><fmt:message key="common.update"/></a>
			<a href="${ctx }/admin/book/delete.do?id=<c:out value="${book.id}"/>"><fmt:message key="common.delete"/></a>
			<a href="${ctx }/admin/bookChapter/create.do?bookId=<c:out value="${book.id}"/>"><fmt:message key="common.add"/><fmt:message key="book.chapter"/></a>
		</td>
	</tr>
	</c:forEach>
	<c:if test="${fn:length(page.result)>0}">
	<tr>
		<td colspan="5">
			<iary:paginate url="${ctx}/admin/book/search.do" param=""/>
		</td>
	</tr>
	</c:if>
	</c:if>
</table>

<br/>
</body>
</html>